home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / Networking / SANA-II / slip_src / slip_device.asm < prev    next >
Encoding:
Assembly Source File  |  1998-06-06  |  3.5 KB  |  192 lines

  1. **
  2. ** $Source: HOG:Other/networking/sana2/src/slip/RCS/slip_device.asm,v $
  3. ** $State: Exp $
  4. ** $Revision: 38.1 $
  5. ** $Date: 94/02/17 14:17:31 $
  6. ** $Author: kcd $
  7. **
  8. ** Amiga SANA2 SLIP Device Driver
  9. **
  10. ** (C) Copyright 1992-1998 Amiga, Inc.
  11. **
  12.  
  13.  
  14.     SECTION    firstsection
  15.  
  16.     NOLIST
  17.  
  18.     include    "exec/types.i"
  19.     include    "exec/devices.i"
  20.     include    "exec/initializers.i"
  21.     include    "exec/memory.i"
  22.     include    "exec/resident.i"
  23.     include    "exec/io.i"
  24.     include    "exec/ables.i"
  25.     include    "exec/errors.i"
  26.     include    "exec/tasks.i"
  27.     include    "utility/tagitem.i"
  28.     include "utility/hooks.i"
  29.     include    "dos/dos.i"
  30.     include    "dos/dosextens.i"
  31.     include    "dos/dostags.i"
  32.     include    "devices/serial.i"
  33.     include    "devices/sana2.i"
  34.     include    "slip_device.i"
  35.         include "slip_rev.i"
  36.  
  37.     LIST
  38.  
  39. ABSEXECBASE    EQU    4    ;Absolute location of the pointer to exec.library base
  40. **
  41. ** First executable location
  42. **
  43.  
  44. FirstAddress:
  45.     moveq    #-1,d0
  46.     rts
  47.  
  48. SLIPPRI   EQU   5
  49.  
  50.     XREF    EndCode
  51.  
  52. initDDescrip:
  53.                     ; STRUCTURE RT,0
  54.     DC.W    RTC_MATCHWORD        ; UWORD    RT_MATCHWORD (Magic cookie)
  55.     DC.L    initDDescrip        ; APTR    RT_MATCHTAG  (Back pointer)
  56.     DC.L    EndCode            ; APTR    RT_ENDSKIP   (To end of this hunk)
  57.     DC.B    RTF_AUTOINIT        ; UBYTE    RT_FLAGS     (magic-see "Init:")
  58.     DC.B    VERSION            ; UBYTE    RT_VERSION
  59.     DC.B    NT_DEVICE        ; UBYTE    RT_TYPE         (must be correct)
  60.     DC.B    SLIPPRI            ; BYTE    RT_PRI
  61.     DC.L    SLIPName        ; APTR    RT_NAME         (exec name)
  62.     DC.L    idString        ; APTR    RT_IDSTRING  (text string)
  63.     DC.L    Init            ; APTR    RT_INIT
  64.                     ; LABEL    RT_SIZE
  65.  
  66. SLIPName:    SLIPDEVNAME
  67.  
  68. ** This is an identifier tag to help in supporting the device
  69. ** format is 'name version.revision (dd MON yyyy)',<cr>,<lf>,<null>
  70.  
  71. idString:    VSTRING
  72.  
  73. ** Force word alignment
  74.  
  75.     ds.w   0
  76.  
  77. Init:
  78.     dc.l    SLIPDev_Sizeof    ; data space size
  79.     dc.l    funcTable    ; pointer to function initializers
  80.     dc.l    dataTable    ; pointer to data initializers
  81.     dc.l    initRoutine    ; routine to run
  82.  
  83. **
  84. ** Standard System Routines
  85. **
  86.  
  87.     XREF    _DevOpen
  88.     XREF    _DevClose
  89.     XREF    _DevExpunge
  90.     XREF    _DevBeginIO
  91.     XREF    _DevAbortIO
  92.     XDEF    _ExtDeviceBase
  93.     XDEF    _DevProcEntry
  94.     XDEF    @IPToNum
  95.     XDEF    _SANA2BuffCall
  96.     XREF    _DevProcCEntry
  97.  
  98. funcTable:
  99.     dc.l    _DevOpen
  100.     dc.l    _DevClose
  101.     dc.l    _DevExpunge
  102.     dc.l    Null
  103.     dc.l    _DevBeginIO
  104.     dc.l    _DevAbortIO
  105.     dc.l    -1
  106.  
  107. dataTable:
  108.     INITBYTE    LN_TYPE,NT_DEVICE    ;Must be LN_TYPE!
  109.     INITLONG    LN_NAME,SLIPName
  110.     INITBYTE    LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  111.     INITWORD    LIB_VERSION,VERSION
  112.     INITWORD    LIB_REVISION,REVISION
  113.     INITLONG    LIB_IDSTRING,idString
  114.     DC.W   0    ;terminate list
  115.  
  116. _ExtDeviceBase    dc.l    0
  117.  
  118. **
  119. ** initRoutine
  120. **
  121. ** Called after device has been allocated.
  122. ** This routine is single threaded
  123. **
  124. ** Register Usage
  125. **
  126. ** a3 - Pointer to temporary RAM
  127. ** a4 - Pointer to expansion.library base
  128. ** a5 - Pointer to device struct
  129. ** a6 - Pointer to Exec Base
  130.  
  131. initRoutine:
  132.     movem.l    d1-d7/a0-a5,-(sp)
  133.     movea.l    d0,a5
  134.     move.l    a6,sd_SysLib(a5)
  135.     move.l    a0,sd_SegList(a5)
  136.     lea.l    FakePFHookEntry(pc),a0
  137.     move.l    a0,sd_DummyPFHook+h_Entry(a5)
  138.     lea.l    sd_Lock(a5),a0
  139.     jsrlib    InitSemaphore
  140.     move.l    a5,d0
  141. Init_Exit:
  142.     movem.l    (sp)+,d1-d7/a0-a5
  143.     rts
  144.  
  145. Null:
  146.     moveq.l    #0,d0
  147.     rts
  148.  
  149. @IPToNum:
  150.     movem.l    d2-d7/a2-a6,-(sp)
  151.     bsr    StrToNum
  152.     lsl.w    #8,d0
  153.     move.w    d0,d4
  154.     bsr    StrToNum
  155.     move.b    d0,d4
  156.     swap    d4
  157.     bsr    StrToNum
  158.     lsl.w    #8,d0
  159.     move.w    d0,d4
  160.     bsr    StrToNum
  161.     move.b    d0,d4
  162.     move.l    d4,d0
  163.     movem.l    (sp)+,d2-d7/a2-a6
  164.     rts
  165.  
  166. StrToNum:
  167.     moveq    #0,d0
  168.     moveq    #0,d1
  169. 1$    move.b    (a0)+,d1
  170.     cmp.b    #'0',d1
  171.     blo    2$
  172.     cmp.b    #'9',d1
  173.     bhi    2$
  174.     sub.b    #'0',d1
  175.     mulu    #10,d0
  176.     add.w    d1,d0
  177.     bra    1$
  178. 2$    rts
  179.  
  180. _DevProcEntry:
  181.     movea.l    _ExtDeviceBase(pc),a6
  182.     jmp    _DevProcCEntry
  183.  
  184. _SANA2BuffCall:
  185.     jmp    (a2)
  186.  
  187. FakePFHookEntry:
  188.     moveq.l    #1,d0
  189.     rts
  190.  
  191.     end
  192.